Logo Programming 

Worksheet for Wednesday, October 9th

 

1.  ROUTINES

A routine is a series of Logo commands, usually used to create a geometric drawing.

For example,    REPEAT 4[FD 50 RT 90]  is a logo routine that draws a square with each side 50 units long.  (Read and try the routines on pages 842-845 and do problems #3-5 on page 852.)

 

2.  PROCEDURES

Defining a procedure:

 A procedure is a series of Logo commands that have been given a specific name so that the computer can store the commands and use them later whenever you use the name of the procedure.  It allows you to create your own dictionary of terms in the Logo program’s short-term memory.   For example,

 

            TO SQUARE

            REPEAT 4[FD 50 RT 90]

            END

 

To indicate that you want to create a procedure you begin with the word TO followed by the name of your procedure.  To indicate you are finished with your instructions you use the word END.  When you define a procedure, no picture is drawn, it just stores the instructions under the name you gave them.

Using a procedure:

To use your procedure to draw a picture you just type its name.  For example, type SQUARE and the computer follows the instructions stored under that name and draws a square.

(Read the middle of page 845 and do problems #6-8 on page 852.)

Variables in a procedure:

You can use a variable in a procedure.  This allows you to use the same set of instructions but use different numbers in place of the variable.  For example, edit your square procedure by typing EDIT SQUARE.  Then type in the :N in the title of your procedure and in place of the 50.

To exit the editor screen use the F2 key at the top of your keyboard.  Do not click on the X in the upper right of the screen since this closes the editor window without saving the changes you made.

            TO SQUARE :N

            REPEAT 4[FD :N RT 90]

            END

 

When you use the procedure you type its name followed by the number you want to use for the variable.  For example, SQUARE 50 will draw a square with each side 50 units long. 

(Note:  When using the procedure you do not type the word TO and you do not type a colon in front of the number 50.)  SQUARE 20 will draw a square with each side 20 units long.

 

** See page 847 for a procedure that defines a parallelogram with variables for the size of 

the angles and sides.  Study the examples of the parallelograms created by using the name of the procedure with different numbers for the angle and sides.  Type into your computer the parallelogram procedure as shown on page 847 and then use it to do # 9 page 852.

Next reread page 845, then do page 853 # L12.1 & L12.2.

 

Using Logo to illustrate symmetry

Worksheet for Friday, October 18th.  Class will be held in BR 161.

 

Create a procedure to make a flag.

To FLAG

FD 60

REPEAT 4 [FD 50 RT 90]

BK 60

END

Type in the word FLAG to have the computer draw a flag.

 

Use this procedure to illustrate rotational symmetry.

Type these routines to experiment with different rotational symmetries.

Keep a record of your results and comment about the rotational symmetry of each.

 

REPEAT 3 [FLAG RT 120]

Type CS to clear the screen and then type:

REPEAT 5 [FLAG RT 72]

Type CS to clear the screen and then type:

REPEAT 6 [FLAG RT 60]

Type CS to clear the screen and then type:

REPEAT 10 [FLAG RT 36]

 

Use a square to illustrate lines of symmetry. 

TO SQUARE :N

REPEAT 4[FD :N RT 90]

END

 

Type in these instructions:

SQUARE 10

SQUARE 20

SQUARE 30

SQUARE 40

Do you see a diagonal line of symmetry?

 

Look for rotational symmetry and lines of symmetry in each figure.  Write down the smallest degrees of rotational symmetry and the number of lines of symmetry and that you see in each figure.

Type in these instructions:

REPEAT 4[SQUARE 50 RT 360/4]

Type CS to clear the screen and then type:

REPEAT 8[SQUARE 50 RT 360/ 8]

Type CS to clear the screen and then type:

REPEAT 12[SQUARE 50 RT 360/ 12

Type CS to clear the screen and then type:

REPEAT 24[SQUARE 50 RT 360/24]

(You can test your ideas about the symmetry by having the turtle draw appropriate lines through the figures.)